<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    div {
      width: 600px;
      height: 300px;
      background-color: pink;
    }

    p {
      cursor: pointer;
    }
  </style>
</head>

<body>
  <div>
    <p>X</p>
  </div>


  <script>


    const p = document.querySelector('p')
    const div = document.querySelector('div')

    p.addEventListener('click', function () {
      div.style.display = 'none'
    })

  </script>

</body>

</html>